package com.xsm.adapter;

import java.util.ArrayList;

import com.xsm.activitygroup.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class SelectAdapter extends BaseAdapter{
	Context context;
	ArrayList<String> values;
	boolean[] isselect;
 public SelectAdapter(Context context,ArrayList<String> values){
	 this.context=context;
	 this.values=values;
	 isselect=new boolean[values.size()];
 }
	public int getCount() {
		return values.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return values.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null)
	    convertView=LayoutInflater.from(context).inflate(R.layout.listtext,null);
		TextView t1=(TextView)convertView.findViewById(R.id.mytext);
		t1.setText(values.get(position));
		if(isselect[position]){
		t1.setBackgroundResource(R.color.blue);
		}else {
		t1.setBackgroundResource(R.color.bg);
		}
		return convertView;
	}

	public void setselect(int i,boolean s){
		isselect[i]=s;
	}
	
	public boolean[] getselect(){
		return isselect;
	}
}
